package com.ogawa.projectcommon.dao

import androidx.room.*
import com.ogawa.projectcommon.bean.CollectBean

@Dao
interface ProgramCollectDao {
    @Query("SELECT * FROM collect")
    fun getCollects(): MutableList<CollectBean>

    /**
     * 根据program与programId查询收藏数据
     */
    @Query("SELECT * FROM collect WHERE type=:type AND program=:modelValue")
    fun queryCollectByTypeAndModel(type: Int, modelValue: String): CollectBean

    /**
     * 根据index查询收藏数据
     */
    @Query("SELECT * FROM collect WHERE `index`=:index")
    fun queryCollectByIndex(index: Int): CollectBean

    @Delete
    suspend fun deleteCollect(collectBean: CollectBean)

    @Update
    fun updateCollectInfo(collectBean: CollectBean)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(collectBean: CollectBean)
}
